<?php
// get the class
require_once('../../plainTemplates/plainTemplates.php');
// always end dir with a slash
plainTemplates::$cacheDir = '../../plainTemplates/cache/';
plainTemplates::clearCache();
//plainTemplates::$debug = true;
$data = array(
	array(
		'Post' => array(
			'title' => 'Im the title',
			'body' => 'Im the body',
		),
		'Comment' => array(
			array(
				'author' => 'Im the 1st comment of 1st post',
				'body' => "This field has same name as post's one",
			),
			array(
				'author' => 'Im the 2nd comment of 1st post',
				'body' => 'So am i',
			),
		),
	),
	array(
		'Post' => array(
			'title' => 'Im the post without comments',
			'body' => 'His right',
		),
		'Comment' => array(),
	),
);
// include to fully preserve scope
include(
	plainTemplates::createTemplate(
		// first the template source
		'template.htm',
		// second the var info
		array(
			// var name in scope
			'$data',
			// and var value
			$data,
			// finally the selectors (of course there are defaults, that is UL and LI)
			array(
				// selectors for 'Post' row
				'container' => '.someclass > ul',
				'row'		=> '> li',
				// selectors for 'Comment'. we have to group them inside 'Comment' index because it's another data (list), not row
				'Comment' => array(
					'container' => '.someclass > ul ul',
				),
			)
		)
	)
);
?>